package com.suncm3kw.chatgpt.service;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.suncm3kw.chatgpt.entity.SseEmitterUTF8;
import com.suncm3kw.chatgpt.listener.SseCompleteListener;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service("chatDataService")
public class AiChatDataService {

	@Autowired
	@Qualifier("baseChatGptService")
    private BaseChatGptService aiChatDataBaseService;  
	
	public void sentSseMessageOrigin(SseEmitterUTF8 emitter,String ApiChatHead,String jsonData, String chatId,boolean isOllama) throws IOException {
		aiChatDataBaseService.sentSseMessageOrigin(emitter, ApiChatHead, jsonData, new SseCompleteListener() {
			 @Override
             public void completeSuscc(String answer, String quote) {
				//SSE传输完成，需要写入聊天记录表
                log.info("调用FastGpt接口,SSE传输完成，写入聊天记录表");
			 }
		},isOllama);
		
	}
    public SseEmitterUTF8 getConn(String sseId) {
        return aiChatDataBaseService.getConn(sseId);
    }
}
